package src.com.doit.Demo09;
//instanceof:判断某个对象是否属于某个类 如果属于返回true 不属于返回false
public class Tese_Istanceof {
    public static void main(String[] args) {
        Animal a = new Cat();
        method(a);
        method(new Dog());
    }
    public static void method(Animal a)
    {
        if (a instanceof Cat)
        {
            Cat c = (Cat)a;
            c.eat();
            c.catchMouse();
        }
        if(a instanceof Dog)
        {
            Dog d = (Dog) a;
            d.eat();
            d.lookDoor();
        }
    }
}
